<template>
  <div class="storage-room-container">
    <!-- 数据表格 -->
    <el-table
        :data="tableData"
        border
        stripe
        v-loading="loading"
        style="width: 100%">
      <!-- 左侧列 -->
      <el-table-column prop="communityName" label="所在小区" width="100" align="center" />
      <el-table-column prop="storageRoomId" label="储藏室ID" width="80" align="center" />
      <el-table-column prop="storageNo" label="储藏室编号" width="100" align="center" />
      <el-table-column prop="floorNo" label="楼层" width="80" align="center" />
      <el-table-column prop="buildingArea" label="建筑面积(㎡)" width="80" align="center">
        <template #default="scope">
          {{ scope.row.buildingArea || '-' }}
        </template>
      </el-table-column>

      <!-- 右侧列 -->
      <el-table-column prop="usableArea" label="使用面积(㎡)" width="80" align="center">
        <template #default="scope">
          {{ scope.row.usableArea || '-' }}
        </template>
      </el-table-column>
      <el-table-column prop="publicArea" label="公摊面积(㎡)" width="80" align="center">
        <template #default="scope">
          {{ scope.row.publicArea || '-' }}
        </template>
      </el-table-column>
      <el-table-column prop="houseType" label="房屋类型" width="80" align="center">
        <template #default="scope">
          {{ scope.row.houseType || '-' }}
        </template>
      </el-table-column>
      <el-table-column prop="description" label="描述" min-width="150" show-overflow-tooltip>
        <template #default="scope">
          {{ scope.row.description || '-' }}
        </template>
      </el-table-column>
    </el-table>

    <!-- 空状态 -->
    <el-empty v-if="tableData.length === 0 && !loading" description="暂无储藏室信息" />
  </div>
</template>

<script setup name="StorageRoomCard">
import { ref, onMounted, watch } from 'vue'

// 定义props
const props = defineProps({
  storageRoomData: {
    type: Array,
    default: () => []
  }
})

const tableData = ref([])
const loading = ref(false)



// 监听props变化
watch(
    () => props.storageRoomData,
    (newData) => {
      tableData.value = newData
    },
    { immediate: true, deep: true }
)

// 初始化数据
onMounted(() => {
  console.log('储藏室数据:', props.storageRoomData)
})
</script>

<style scoped lang="scss">
.storage-room-container {
  padding: 0;

  :deep(.el-table) {
    .el-table__header-wrapper {
      background-color: #f5f7fa;
    }

    .el-table__row {
      &:hover {
        background-color: #f5f7fa;
      }
    }
  }
}
</style>